package com.zhuj.codec;

import com.alibaba.fastjson.JSON;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageEncoder;

import java.util.List;

public class NrpcJsonEncode extends MessageToMessageEncoder<Object> {

    protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> list) throws Exception {
        long a = System.currentTimeMillis();
        String message = JSON.toJSONString(msg)+System.getProperty("line.separator");
        list.add(message);
        System.out.println("编码毫秒数："+(System.currentTimeMillis()-a));
    }
}
